package com.naver.xml.gson;

import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;

public class GsonReadingTest {
	class Rts {
		String type;
		String id;
		Geometry geometry;
		Properties properties;

		class Geometry {
			String type;
			List<List<Double>> coordinates = new ArrayList<List<Double>>();
		}

		class Properties {
			String ROAD_K;
			String LINK_K;
			String LANE_NUM;
			String N_U_LINK;
			String N_D_LINK;
			String LINK_L;
			String MAX_SPEED;
			String DSV_COUNT;
			String TWO_WAY;
			String RD_DISTANCE;
			String SC_NEXT_NAME;
			String SC_STATE;
			String RD_SPEED;
			String SC_EP_NAME;
			String SC_PREV_NAME;
			String RD_MINUTE;
			String RD_NAME;
			String SC_MINUTE;
			String SC_NEXT_SID;
			String SC_SPEED;
			String SC_SP_NAME;
			String SC_PREV_SID;
		}
	}

	public static void main(String[] args) throws IOException {
		Gson gson = new Gson();
		URL url = new URL("http://rts1.map.naver.net/rts/wms?request=GetTrafficInfo&crs=EPSG:4326&level=14&x=126.3715314&y=33.2650986");
		InputStreamReader inputStreamReader = new InputStreamReader(url.openStream());
		JsonReader reader = new JsonReader(inputStreamReader);
		Rts rts = gson.fromJson(reader, Rts.class);
		System.out.println(rts.type);
		System.out.println(rts.properties.SC_SP_NAME);
		System.out.println(rts.geometry.coordinates.get(0));

	}
}
